﻿
@{
    ViewBag.Title = "BudgetNotificationAdd";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css {
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <style>
        th {
            text-align: center;
            font-weight: bold;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}
<div class="page-content" ng-cloak ng-controller="SafetyCostController" ng-init="
     Id='@(Request.QueryString["Id"].IsEmpty() ? "" : Request.QueryString["Id"])';
      page='@(Request.QueryString["page"].IsEmpty() ? "" : Request.QueryString["page"])';
     TotalAmount=0;
      ApplyItems = [];


      GetSafetyCostOption();
     GetSafetyCostApplyDetail(Id);
      GetSafetyFormFile(Id);
    ">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />

			</path>
		</svg>
            <div class="load-msg">正在加载...</div>
        </div>
    </div>
    <div class="page-heading">
        <h1>安全费用使用申请编辑</h1>
        <div class="options">
            <div class="btn-toolbar">

            </div>
        </div>
    </div>
    <ol class="breadcrumb">
        <li><a>主体业务</a></li>
        <li><a>安全费用</a></li>
        <li class="active"><a>安全费用使用申请编辑</a></li>
    </ol>

    <div class="container-fluid">
        <div class="row">
            <form class="form-horizontal row-border">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading"><h2>安全费用使用申请</h2></div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>申请部门：</label>
                                <div class="col-sm-3">
                                    <input class="form-control" type="text" disabled value="{{CostDetail.DepartmentName}}" />
                                </div>
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>申请人：</label>
                                <div class="col-sm-3">
                                    <input class="form-control" type="text" disabled value="{{CostDetail.CreateUserName}}" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>使用日期：</label>
                                <div class="col-sm-2">
                                    <datepicker id="startTime" option="datetimeOption" format="L" ng-model="CostDetail.ApplyDate|JSONDate:'yyyy-MM-dd'"></datepicker>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>已添加费用开支：</label>
                                <div class="col-sm-10">
                                    <table class="table table-striped table-bordered table-hover">
                                        <thead>
                                            <tr>
                                                <th style="width:5%">序号</th>
                                                <th style="width:30%">使用范围</th>
                                                <th style="width:10%">事由</th>
                                                <th style="width:10%">预计金额</th>
                                                <th style="width:10%">备注</th>
                                                <th style="width:10%">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr ng-show="CostDetail.ApplyItems==0">
                                                <td colspan="4" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                            </tr>
                                            <tr ng-repeat="x in CostDetail.ApplyItems">
                                                <td>{{$index+1}}</td>
                                                <td>{{x.RangeModel.Title +'.'+ x.RangeModel.Content}}</td>
                                                <td>{{x.Option}}</td>
                                                <td>{{x.Amount}} {{x.Amount|TransCurrency}}</td>
                                                <td>{{x.Remark}}</td>
                                                <td><a ng-click="DeleteCostApplyItems(x,CostDetail.ApplyItems,ApplyItems);" class="btn btn-danger btn-xs btn-label"><i class="fa fa-trash"></i>删除</a></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>费用开支：</label>
                                <div class="col-sm-1" ng-show="ApplyItems.length==0">
                                    <button class="btn btn-primary-alt" ng-click="AddApplyItem(ApplyItems);CalcCostApplyEditTotal(CostDetail.ApplyItems,ApplyItems);">添加</button>
                                </div>
                                <div class="col-sm-11">
                                    <div class="form-group" ng-repeat="x in ApplyItems">
                                        <div class="col-sm-10" style="background-color:rgb(246,248,248);">
                                            <div class="row" style="padding-top:10px;">
                                                <label class="col-sm-1 control-label"><b style="color:red;"></b>使用范围:</label>
                                                <div class="col-sm-2" style="padding-top:4px;">
                                                    <a class="btn btn-sm btn-default btn-label" ng-click="GetUsageRangeList();SetCurrentIndex(x.Index);" data-toggle="modal" href="#UsageRangeModal"><i class="fa fa-cog"></i>选择使用范围</a>
                                                </div>
                                                <div class="col-sm-4" id="range_{{$index}}">

                                                </div>
                                                <label class="col-sm-2 control-label"><b style="color:red;"></b>预算使用金额:</label>
                                                <div class="col-sm-2">
                                                    <input class="form-control" type="number" ng-model="x.Amount" ng-change="CalcCostApplyEditTotal(CostDetail.ApplyItems,ApplyItems);" />
                                                </div>
                                            </div>
                                            <div class="row" style="margin-top:20px;">
                                                <label class="col-sm-1 control-label"><b style="color:red;"></b>费用事项:</label>
                                                <div class="col-sm-10">
                                                    <label class="radio-inline" ng-repeat="y in CostOption">
                                                        <input type="radio" value="{{y.Id}}" name="OptionSelect_{{$parent.$index}}"> {{y.OptionContent}}
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="row" style="margin-top:20px;">
                                                <label class="col-sm-1 control-label"><b style="color:red;"></b>备注:</label>
                                                <div class="col-sm-9">
                                                    <textarea class="form-control" ng-model="x.Remark"></textarea>
                                                </div>
                                            </div>
                                            <div class="row" style="margin-top:20px;margin-bottom:10px;">
                                                <label class="col-sm-1 control-label"><b style="color:red;"></b>实际使用:</label>
                                                <div class="col-sm-2">
                                                    <input class="form-control" disabled ng-model="x.CostAmount" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <button class="btn btn-danger" ng-click="RemoveApplyItems(x,ApplyItems);CalcCostApplyEditTotal(CostDetail.ApplyItems,ApplyItems);">移除</button>
                                            <button class="btn btn-primary-alt" ng-show="$index==ApplyItems.length-1" ng-click="AddApplyItem(ApplyItems);CalcCostApplyEditTotal(CostDetail.ApplyItems,ApplyItems);">添加</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>附件：</label>
                                <div class="col-sm-8">
                                    <table class="table table-striped table-bordered table-hover">
                                        <thead>
                                            <tr>
                                                <th style="width:5%">序号</th>
                                                <th style="width:30%">文件名称</th>
                                                <th style="width:10%">文件大小(kb)</th>
                                                <th style="width:10%">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr ng-show="FileList.length==0">
                                                <td colspan="4" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                            </tr>
                                            <tr ng-repeat="x in FileList">
                                                <td ng-bind="$index+1"></td>
                                                <td ng-bind="x.FileName"></td>
                                                <td ng-bind="x.FileSize"></td>
                                                <td>
                                                    <a href="../Download/DownloadFile?FileId={{x.FileId}}" class="btn btn-success btn-xs btn-label"><i class="fa fa-download"></i>下载</a>
                                                    <a ng-click="DeleteSafetyCostFile(x,FileList);" class="btn btn-danger btn-xs btn-label"><i class="fa fa-trash"></i>删除</a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            @*<div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>下级批准人：</label>
                                <div class="col-sm-8">
                                    <select id="approve_list" class="selectpicker show-tick form-control" ng-model="CostDetail.ApproveUser" ng-change="refreshOption('approve_list');" data-live-search="true">
                                        <option value="" selected>选择审核人</option>
                                    </select>
                                </div>
                            </div>*@
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>附件上传：</label>
                                <div class="col-sm-8">
                                    <input type="file" class="form-control" id="taskfile" />
                                </div>
                            </div>
                        </div>
                        <div class="panel-footer">
                            <p style="font-size:15px;font-weight:bold;">预计使用总金额：<span style="color:orange;font-size:22px;">{{TotalAmount}}</span><span style="margin-left:20px;">{{TotalAmount|TransCurrency}}</span></p>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                </div>
                <div class="col-md-1">
                    <button class="btn-primary btn" ng-click="EditSafetyCostApplyForm(CostDetail,ApplyItems,0)">保存</button>
                </div>
                <div class="col-md-1">
                    <button class="btn-primary btn" ng-click="EditSafetyCostApplyForm(CostDetail,ApplyItems,1)">提交</button>
                </div>
                <div class="col-md-1">
                    <a href="CostRecordList?page={{page}}" class="btn-default btn">返回</a>
                </div>
                <div class="col-md-3">
                </div>
            </form>

        </div>
    </div>

    <div class="modal fade" id="UsageRangeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:1250px;">
            <div class="modal-content" style="min-height: 700px;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">选择使用范围</h2>
                </div>
                <div class="modal-body" style="min-height: 660px;">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <div class="checkbox" style="margin-top:5px;" ng-repeat="x in UsageRangeList"><label><input type="radio" value="{{x.Id}}" name="usagerangelist">&nbsp;&nbsp;{{x.Title}}&nbsp;.&nbsp;{{x.Content}}</label></div>
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close">关闭</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="SelectUsageRange(CurrentIndex,ApplyItems);">确认</button>
                </div>
            </div>

        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>

@section Js{
    <script src="~/Assets/plugins/form-ckeditor/ckeditor.js"></script>
    <script src="~/Assets/js/libs/upload.js"></script>
    <script src="~/Assets/js/pg/SafetyCost.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/Assets/js/libs/moment.min.js"></script>
    <script src="~/Assets/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/Assets/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Assets/js/libs/angularjs-datepicker.js"></script>
    <script src="~/Assets/js/libs/fileinput.js"></script>
    <script src="~/Assets/js/libs/zh.js"></script>
    <script>
        $('#SelectedCheckList').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });
    </script>
}
